#pragma once

#include "RHITexture.h"

class CustomTexture : public RHITexture
{
	struct BuilderDetails {

		bool isMultiple;

		VkImageCreateFlags flags;
		VkImageType imageType;
		VkFormat format;
		VkExtent3D extent;
		uint32 mipLevels;
		uint32 arrayLayers;
		VkSampleCountFlagBits samples;
		VkImageTiling tiling;
		VkImageUsageFlags usage;
		VkSharingMode sharingMode;
		VkImageLayout imageLayout;
		VkMemoryPropertyFlags mMemoryProperty;
		std::vector<VkQueueFlagBits> queueFamilys;

		VkImageViewType viewType;
		VkComponentMapping components;
		VkImageSubresourceRange subresourceRange;

		void* data;

		BuilderDetails();
	};

public:

	class Builder : public BuilderBase<BuilderDetails> {
		friend struct BuilderDetails;
	public:
		Builder() noexcept;
		Builder(Builder const& rhs) noexcept;
		Builder(Builder&& rhs) noexcept;
		~Builder() noexcept;
		Builder& operator=(Builder const& rhs) noexcept;
		Builder& operator=(Builder&& rhs) noexcept;

		Builder& SetMultiple(bool isMultiple) noexcept;

		Builder& SetFlags(VkImageCreateFlags flags) noexcept;
		Builder& SetImageType(VkImageType imageType) noexcept;
		Builder& SetFormat(VkFormat format) noexcept;
		Builder& SetExtent(VkExtent3D extent) noexcept;
		Builder& SetWidth(uint32 width) noexcept;
		Builder& SetHeight(uint32 height) noexcept;
		Builder& SetDepth(uint32 depth) noexcept;
		Builder& SetMipLevels(uint32 mipLevels) noexcept;
		Builder& SetArrayLayers(uint32 arrayLayers) noexcept;
		Builder& SetSamples(VkSampleCountFlagBits samples) noexcept;
		Builder& SetTiling(VkImageTiling tiling) noexcept;
		Builder& SetUsage(VkImageUsageFlags usage) noexcept;
		Builder& SetSharingMode(VkSharingMode sharingMode) noexcept;
		Builder& SetImageLayout(VkImageLayout imageLayout) noexcept;
		Builder& SetMemoryProperty(VkMemoryPropertyFlags mMemoryProperty) noexcept;
		Builder& AddQueueFamily(VkQueueFlagBits queueFlag) noexcept;

		Builder& SetViewType(VkImageViewType viewType) noexcept;
		Builder& SetComponents(VkComponentMapping components) noexcept;
		Builder& SetAspectMask(VkImageAspectFlags aspectMask) noexcept;
		Builder& SetBaseMipLevel(uint32 baseMipLevel) noexcept;
		Builder& SetLevelCount(uint32 levelCount) noexcept;
		Builder& SetBaseArrayLayer(uint32 baseArrayLayer) noexcept;
		Builder& SetLayerCount(uint32 layerCount) noexcept;

		Builder& SetData(void* data) noexcept;

		RefCountPtr<CustomTexture> Build();
		RefCountPtr<CustomTexture> Build(RenderProcess* process, const std::string& name);

	private:
		friend class ColorTexture;
	};

	CustomTexture(BuilderDetails& builderDetails);

	virtual void ReleaseResource() override;

};